home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / AppleScript for Acrobat plug-in / SOURCES / STAMPER.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  2.4 KB  |  88 lines

  1. /******************************************************************************
  2.  
  3. Stamper.c
  4.  
  5. This file is furnished to you by Adobe Systems Incorporated 
  6. under the terms of the Acrobat(r) Plug-ins Software 
  7. Development Kit License Agreement.
  8.  
  9. Copyright (C) 1994-1997, Adobe Systems Inc.  All Rights Reserved.
  10.  
  11.  
  12. Implementation of the handshaking and initialization code
  13. for Stamper, a plug-in that demonstrates a simple annotation
  14. handler.
  15.  
  16. To see the callbacks, #define the DEBUGWIN macro and install
  17. the DebugWin plug-in.
  18.  
  19. ******************************************************************************/
  20.  
  21. #include "PICommon.h"
  22. #include "CorCalls.h"
  23. #include "stampah.h"
  24. #include "stampui.h"
  25. #include "AVCalls.h"
  26.  
  27. ASAtom Stamper_K;
  28. ASAtom Annotation_K;      
  29.  
  30.  
  31. #define DEBUGWIN 0
  32. #include "debugger.h"
  33. HFT gDebuggerWindowHFT;
  34. static ACCB1 ASBool ACCB2 importHFTs(void)
  35. {
  36.     gDebuggerWindowHFT = ASExtensionMgrGetHFT(ASAtomFromString("ADBE_DebuggerWindow"), 1);
  37.     return true;
  38. }
  39.  
  40. static ACCB1 ASBool ACCB2 StamperInit(void)
  41. {
  42.  
  43. AVAppRegisterNotification(AVAppDidInitializeNSEL,0, SetUpStamperAnnotHandler, NULL);
  44.     SetUpUI(); 
  45.     if (gDebuggerWindowHFT)
  46.         ShowDebuggerWindow();
  47.  
  48.     return true;
  49. }
  50.  
  51. static ACCB1 ASBool ACCB2 Stamper_Unload(void)
  52. {
  53.     
  54.     AVAppUnregisterNotification(AVAppDidInitializeNSEL,0, SetUpStamperAnnotHandler, NULL);
  55.     CleanUpUI();
  56.     return true;
  57. }
  58. /*
  59. ** PIHandshake
  60. ** Required Plug-in handshaking routine: Do not change it's name!
  61. */
  62. ACCB1 ASBool ACCB2 PIHandshake(Uns32 handshakeVersion, void *handshakeData)
  63. {
  64.     /* hmmmm, I wonder if I should change the name of Stamper_K? */
  65.     Stamper_K = ASAtomFromString("ADBE_Stamper");
  66.     Annotation_K = ASAtomFromString("Annotation");
  67.     
  68.     if (handshakeVersion == HANDSHAKE_V0200)
  69.     {
  70.         PIHandshakeData_V0200 *hsData = (PIHandshakeData_V0200 *)handshakeData;
  71.  
  72.         hsData->extensionName = ASAtomFromString("ADBE_AppleScript");       
  73. #if DEBUGWIN
  74.         hsData->importReplaceAndRegisterCallback = ASCallbackCreateProto( PIImportReplaceAndRegisterProcType, &importHFTs);
  75. #endif
  76.         hsData->initCallback = ASCallbackCreateProto(PIInitProcType, &StamperInit);
  77.         
  78.         hsData->unloadCallback = Stamper_Unload;
  79.         return true;
  80.     }
  81.     
  82.     /*
  83.     ** If we reach here, then we were passed a handshake version number we don't know about.
  84.     ** This shouldn't ever happen since our main() routine chose the version number.
  85.     */
  86.     return false;
  87. }
  88.